using System;
using Dimok.Data.DataSources;

namespace Data.DataSources {
	public class PurchaseBatchesDataSource : ObjectDataSourceBase {
		public override string SelectViewName { get { return "v_PurchaseBatch"; } }
		public override string InsertViewName { get { return "t_PurchaseBatch"; } }
		public int ContractHolderID {
			set {
				if (value >= 0) {
					SetSelectParameter(CONTRACT_HOLDER_ID, value);
				} else {
					RemSelectParameter(CONTRACT_HOLDER_ID);
				}
			}
		}
		protected override void OnInit(EventArgs e) {
			base.OnInit(e);
			Selecting += new System.Web.UI.WebControls.ObjectDataSourceSelectingEventHandler(PurchaseBatchesDataSource_Selecting);
		}

		void PurchaseBatchesDataSource_Selecting(object sender, System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs e) {
			if (GetSelectParameter(CONTRACT_HOLDER_ID) != null)
				SelectMethod = "SelectByContractHolder";
			else SelectMethod = SELECT_METHOD;
		}
		public System.Data.DataView SelectByContractHolder(int ContractHolderID) {
			return base.Select("ContractHolderID=@ContractHolderID", ContractHolderID);
		}
	}
}